package day10.homework;

public class Student {
		private int id;
		private String name;
		private int age;
		
		public Student(){
			super();
		}
		
		public Student(int id, String name, int age ){
				super();
				this.setId(id);
				this.setName(name);
				this.setAge(age);
		}
		
		@Override
		public boolean equals(Object obj){
				if(obj == null){
				return false;
				}else if(obj instanceof Student){ //instance向父类兼容
						Student s = (Student)obj;
						return s.id ==this.id;
				}return false;
		}
		
		@Override
		public int hashCode(){
				int type = 37;
				return type * 41 + id;
		}
		
		public int getAge(){
				return age;
		}
		
		public void setAge(int age){
				if(age>5&&age<80) {
						this.age = age;
				}else{
						System.out.println("你输入的年龄不符合规范!");
				}
		}
		
		public String getName(){
				return name;
		}
		
		public void setName(String name){
				this.name=name;
		}
		
		public int setId(int id){
				return 0;
		}
}